﻿using B.S.Orders.ErrorCord;
using B.S.Orders.Write.Api.Application.Command.ProjectCommand;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Orders.Write.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProjectController : ControllerBase
    {
        private readonly IMediator mediator;

        public ProjectController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 添加项目信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> CreateProject(CreateProjectCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 删除项目信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> DelProject(DelProjectCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 修改项目信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> UpdProject(UpdProjectCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
